package net.qhzw.vip.qiyu.mapper;

import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.qhzw.vip.qiyu.dto.MyOrderDto;
import net.qhzw.vip.qiyu.dto.OrderCountData;
import net.qhzw.vip.qiyu.dto.PayInfoDto;
import net.qhzw.vip.qiyu.dto.UserShoppingDataDto;
import net.qhzw.vip.qiyu.entity.Order;
import net.qhzw.vip.qiyu.param.OrderParam;
import net.qhzw.vip.qiyu.util.PageAdapter;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

public interface OrderMapper extends BaseMapper<Order> {

    Order getOrderByOrderNumber(@Param("orderNumber") String orderNumber);

    List<Order> listOrderAndOrderItems(@Param("orderStatus") Integer orderStatus,
                                       @Param("lessThanUpdateTime") DateTime lessThanUpdateTime);

    void cancelOrders(@Param("orders") List<Order> orders, @Param("status") Byte status);

    void confirmOrder(@Param("orders") List<Order> orders);

    void updateByToPaySuccess(@Param("orderNumbers") List<String> orderNumbers,
                              @Param("payType") Integer payType);

    List<Order> listOrdersDetialByOrder(@Param("orderNumber") String orderNumber,
                                        @Param("shippingType") Integer shippingType,
                                        @Param("status") Integer status,
                                        @Param("isPayed") Integer isPayed,
                                        @Param("startTime") Date startTime,
                                        @Param("endTime") Date endTime);

    List<Order> listOrdersDetialByOrderParam(@Param("adapter") PageAdapter adapter,
                                             @Param("orderParam") OrderParam orderParam);

    Long countOrderDetial(@Param("orderParam") OrderParam orderParam);

    List<Long> listBoughtProdByUserIdAndShopId(@Param("shopId") Long shopId,
                                               @Param("userId") Long userId);

    UserShoppingDataDto calculateUserInShopData(@Param("shopId") Long shopId,
                                                @Param("userId") Long userId);

    List<MyOrderDto> listMyOrderByUserIdAndStatus(@Param("adapter") PageAdapter adapter,
                                                  @Param("userId") Long userId,
                                                  @Param("status") Integer status);

    Long countMyOrderByUserIdAndStatus(@Param("userId") Long userId,
                                       @Param("status") Integer status);

    void deleteOrders(@Param("orders") List<Order> orders);

    OrderCountData getOrderCount(Long userId);


    PayInfoDto refundPay(@Param("userId") Long userId,
                         @Param("orderNumber") String orderNumber);

    /**
     * 退款
     * @param orderNumber
     */
    void refund(String orderNumber);
}
